<?php

namespace App\Http\Controllers;

use App\Http\Requests\ShouqianbaSetting\SettingEditRequest;
use App\Http\Requests\ShouqianbaSetting\SettingListRequest;

use App\Services\ShouqianbaSetting;
use D1M\Common\Helpers\Result;

class ShouqianbaSettingController
{
    public function getList(SettingListRequest $request, ShouqianbaSetting $service)
    {
        $shopBns = $request->post('data')['shop_bn'];
        if (empty($shopBns)) {
            return Result::fail('请传入正确的门店编码');
        }
        if (count($shopBns) > 200)
            return Result::fail('编码数量不能超过200个');
        $res = $service->getList($shopBns);
        return Result::success($res);
    }

    public function setting(SettingEditRequest $request, ShouqianbaSetting $service)
    {
        $params = $request->post('data');
        $res = $service->setting($params);
        return $res['error'] ? Result::fail($res['message']) : Result::success();
    }
}